<template>
	<view class="logisticsInformation">
		<view class="content" v-for="(item,index) in info" :key="index">
          <view class="line">
			  <text>运单号：{{item.express_no}}</text>
			  <text class="copy" @click="getcopy(index)">复制</text>
		  </view>
		   <view class="line">
			   <text>快递公司：{{item.express_company}}</text>
		   </view>
		   <view class="deliveryInfo">
			   <view class="deliveryItem" v-for="(item2,index2) in item.delivery_list" :key="index2">
				   <view class="time">{{item2.time}}</view>
				   <view class="context">{{item2.context}}</view>
			   </view>
		   </view>
		</view>
	</view>
</template>

<script>
	import serve from '../../static/request.js';
	import storage from '../../static/appkey.js';
	import common from '../../static/jump.js';
	export default {
		data() {
			return {
				id: 0,
				info: {},
			}
		},
		methods: {
			getcopy(key){
				let express_no = this.info[key].express_no;
				uni.setClipboardData({
					data: express_no,
					success: function (){
						uni.showToast({
							title: '复制成功',
							icon: 'none',
						});
					},
					fail:function(){
						uni.showToast({
							title: '对不起，您微信当前版本不支持复制功能',
							icon: 'none',
						});
					}
				});
				uni.getClipboardData({
				    success: function (res) {
				        console.log(res.data);
				    }
				});
			},
			getInfo() {
				var self = this;
				serve.request({
					url: '/member/order/delivery',
					data: {
						id: self.id
					}
				}).then(res => {
					if(res.code != 200) {
						uni.showToast({
							title:res.message,
							icon: 'none',
							success() {
								setTimeout(function () {
									self.jump('order_view', self.id)
								}, 2000) 
							}
						});
					}
					self.info = res.data;
				});
			},
			jump(jump_type, jump_link){
				common.jump(jump_type, jump_link);
			}
		},
		onLoad(options) {
			this.id=options.id || 0;
			if(this.id == 0) {
				uni.showToast({
					title: "错误的访问方式",
					icon: 'none',
					success() {
						setTimeout(function () {
							self.jump('my_order_list')
						}, 2000) 
					}
				});
			}
			this.getInfo();
		},
		onPullDownRefresh() {
			console.log('refresh');
			this.getInfo();
		}
	}
</script>

<style scoped lang="scss">
	.logisticsInformation {
		min-height: 100vh;
		background: #FBFBFD;
		padding-bottom: 50rpx;
		.content {
			box-sizing: border-box;
			width: 100%;
			padding: 20upx 30upx;
			background: #FFFFFF;
			.line{
				font-size: 32upx;
				.copy{
					color: #FFC600;
					font-size: 24upx;
					padding: 0upx 20upx;
					border: 1upx #FFC600 solid;
					margin-left: 40upx;
				}
			}
			.line:last-child{
				padding-top: 30upx;
			}
		}
		.deliveryInfo {
			padding: 0;
			border: 1rpx solid #ccc;
			background: rgba(204,204,204,0.15);
			border-radius: 20rpx;
			margin-top: 10rpx;
			font-size: 30rpx;
			
			.deliveryItem {
				padding: 10rpx;
				color: #999;
			}
			.time {
				font-size: 32rpx;
			}
		}
	}
</style>
